package com.ble.adapter;

import com.ble.App;
import com.ble.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.inuker.bluetooth.library.Constants;
import com.inuker.bluetooth.library.search.SearchResult;

public class QuickAdapter extends BaseQuickAdapter<SearchResult, BaseViewHolder> {
    public QuickAdapter() {
        super(R.layout.item_scan_device);
    }

    @Override
    protected void convert(BaseViewHolder helper, SearchResult item) {
        int status = App.getBle().getConnectStatus(item.getAddress());
        String states = "";
        if ( status == Constants.STATUS_DEVICE_CONNECTED) {
            states = "Disconnected";
        } else {
            states = "Disconnected";
        }
        helper.setText(R.id.deviceName, item.getName())
                .setText(R.id.deviceMac, item.getAddress())
                .setText(R.id.tv_device_state, states)
                .setText(R.id.deviceRssi, String.valueOf(item.rssi));
    }
}
